{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Flasky - 个人中心{% endblock%}

{% block page_content %}
<div class="page-header">
    <img class="=img-rounded profile-thumbnail" src="{{ user.gravatar(size=256) }}">
    <div class="profile-header">
        <h1>{{ user.username|capitalize }}</h1>
    {% if user.name %}
    <p>
        真实姓名：{% if user.name %}{{ user.name }}{% endif %}
    </p>
    {% endif %}

    {% if current_user.is_administrator() %}
    <p>个人邮箱：<a href="mailto:{{ user.email }}">{{ user.email }}</a></p>
    {% endif %}
    {% if user.about_me %}<p>个人介绍：{{ user.about_me }}</p>{% endif %}
    <p>
        注册时间： {{ moment(user.member_since).format('L') }}，
        {{ moment(user.last_seen).fromNow() }}来过。
    </p>
    <p>
        {% if current_user.can(Permission.FOLLOW) and user != current_user %}
            {% if not current_user.is_following(user) %}
            <a href="{{ url_for('.follow', username=user.username) }}" class="btn btn-primary">关注</a>
            {% else %}
            <a href="{{ url_for('.unfollow', username=user.username) }}" class="btn btn-default">取消关注</a>
            {% endif %}
        {% endif %}
        <a href="{{ url_for('.followers', username=user.username) }}">粉丝：
            <span class="badge">
                {{ user.followers.count() - 1 }}
            </span>
        </a>
        <a href="{{ url_for('.followed_by', username=user.username) }}">关注：
            <span class="badge">
                {{ user.followed.count() - 1 }}
            </span>
        </a>
        {% if current_user.is_authenticated and user != current_user and user.is_following(current_user) %}
        | <span class="label label-default">关注了你</span>
        {% endif %}
    </p>
    <p>
        {% if user == current_user %}
        <a class="btn btn-default" href="{{ url_for('.edit_profile') }}">修改资料</a>
        {% endif %}
        {% if current_user.is_administrator() %}
        <a class="btn btn-danger" href="{{ url_for('.edit_profile_admin', id=user.id) }}">修改资料（管理员）</a>
        {% endif %}
    </p>
    </div>
</div>
<h3>{{ user.username}}的文章：</h3>
{% include '_posts.html' %}

{% endblock %}
